
const router = require('koa-router')();
router.prefix('/stu')

router.post('/login',async(ctx)=>{
	let params = ctx.request.body;
		// let params = ctx.query;
		console.log(params)
	let sql = `call stuLogin("${params.stuNum}","${params.password}","${ctx.request.ip}")`;
	console.log(sql)
	try{
		let result = await ctx.mysql.query(sql);
		console.log(result);
		if(result[0][0][0] == 0){
			ctx.body = {err:"404"} //密码或用户名错误
		}else{
			console.log(result[0][0]);
			ctx.body = result[0][0];
		}
	}catch(err){
		console.log(err);
		ctx.body = {err:"server_err"};
	}
});
module.exports = router